import java.util.Scanner;

public class Test {
    public static boolean isLegal(char a) {
        if (a >= 'a' && a <= 'z' || a >= '0' && a <= '9') {
            return true;
        }
        return false;
    }

    public static boolean isPalindrome(String s) {
        s = s.toLowerCase();

        int left = 0;
        int right = s.length() - 1;

        while (left < right) {

            while (left < right && !isLegal(s.charAt(left))) {
                left++;
            }

            while (left < right && !isLegal(s.charAt(right))) {
                right--;
            }

            if (s.charAt(left) != s.charAt(right)) {
                return false;
            } else {
                right--;
                left++;
            }
        }

        return true;
    }
    
    public static void main(String[] args){
        System.out.println(isPalindrome("abcd,eff,edcba"));
    } 
}
